package il.ac.technion;

import java.util.ArrayList;

public class Dao<Type extends IDaoStorable> {
	protected ArrayList<Type> objects = new ArrayList<Type>();

	public void saveObject(Type o) {
		o.setId(objects.size() + 1);
		objects.add(o);
	}

	public Type getObjectById(int id) {
		if (id > 0 && id <= objects.size())
			return objects.get(id - 1);
		return null;
	}

	public ArrayList<Type> getObjects() {
		return objects;
	}
}
